from PySide6.QtCore import Qt
from PySide6.QtWidgets import QDialog, QVBoxLayout
from qfluentwidgets import PrimaryPushButton, FluentIcon as FIF

class VideoSourceDialog(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowTitle("选择视频来源")
        self.resize(300, 150)
        
        # 创建布局
        layout = QVBoxLayout(self)
        
        # 创建按钮
        self.localButton = PrimaryPushButton('本地视频', self)
        self.localButton.setIcon(FIF.VIDEO)
        self.networkButton = PrimaryPushButton('网络视频', self)
        self.networkButton.setIcon(FIF.GLOBE)
        
        # 添加按钮到布局
        layout.addWidget(self.localButton)
        layout.addSpacing(10)  # 添加间距
        layout.addWidget(self.networkButton)
        
        # 设置布局的对齐方式和边距
        layout.setAlignment(Qt.AlignCenter)
        layout.setContentsMargins(20, 20, 20, 20)
        
        # 连接信号
        self.localButton.clicked.connect(self._onLocalVideoClicked)
        self.networkButton.clicked.connect(self._onNetworkVideoClicked)
        
        # 设置窗口属性
        self.setWindowFlags(Qt.Dialog | Qt.MSWindowsFixedSizeDialogHint)
        
    def _onLocalVideoClicked(self):
        self.done(1)  # 1 表示本地视频
        
    def _onNetworkVideoClicked(self):
        self.done(2)  # 2 表示网络视频 